<template>
  <el-container>
    <el-main>
      <el-form ref="productForm" :model="form" label-width="110px" label-position="right">
        <div style="display: flex">

          <el-form-item label="商品名称" style="width: 1200px"  >
            <!-- <span>{{form.name}}</span> -->
            <el-input v-model="form.name"  disabled/>
          </el-form-item>
        </div>

        <div style="display: flex">
          <el-form-item label="商品价格" style="width: 400px" >
            <el-input v-model="form.price"  disabled/>
              <!-- <span>{{form.price}}</span> -->
          </el-form-item>
          
          <el-form-item label="结算价" style="width: 400px">
              <el-input v-model="form.cost" disabled />
              <!-- <span>{{form.cost}}</span> -->
          </el-form-item>


        </div>
        <div style="display: flex">
          <el-form-item label="SKU编码/条码" style="width: 400px" >
              <el-input v-model="form.sn"  disabled/>
              <!-- <span>{{form.sn}}</span> -->
          </el-form-item>

          <el-form-item label="描述" style="width: 400px">
            <!--可搜索带选择框-->
            <el-input v-model="form.subTitle" disabled />
             <!-- <span>{{form.subTitle}}</span> -->
          </el-form-item>

        </div>
           <el-tabs>
          <el-tab-pane label="详情">
            <div class="menu-wrapper">
              <tinymce v-model="form.content" :height="300" :width="950" />
<!-- 
              <el-row>
                <div class="photo-content">
                  <div style="margin-top: 20px">
                    <span style="font-size: 18px;color:#409EFF;">轮播图(最多五张)</span>
                  </div>
                </div>
                <el-col :span="15">
                  <multiUploadDraggable v-model="article.productMeta.images" />
                </el-col>
              </el-row>

              <el-row>
                <div class="photo-content">
                  <div style="margin-top: 20px;">
                    <span style="font-size: 18px;color:#409EFF;margin: 10px 0;">视频介绍</span>
                  </div>
                </div>
                <el-col :span="8">
                  <video-upload v-model="article.productMeta.video" />
                </el-col>
              </el-row> -->
            </div>
          </el-tab-pane>
        </el-tabs>

      </el-form>
    </el-main>
  </el-container>
</template>
<style lang="scss" scoped>
  .photo-content{
    width: 100%;
    display: flex;
    align-items: flex-end;
    border-top: 1px #eee solid;
    margin-bottom: 20px;
    margin-top: 10px;
  }
  /deep/.el-input__inner{
    padding: 0 5px;
  }
  /deep/ .el-upload--picture-card{
    width: 50px !important;
    height: 50px !important;
    line-height: 50px !important;
    text-align: center;
    .menu-wrapper {
      margin: 15px;
    }
  }
</style>
<script>
import store from '@/store'
import {find as marketProductFind} from "@/api/jdproduct";
import Tinymce from '@/components/Tinymce'
export default {
  name: 'ProductEdit',
  components:{
    Tinymce
  },
  // directives: { permission },
  filters: {
    watchType(val) {
        if (val == true) {
          return "已添加";
        } else{
          return "未添加";
        }
      },
  },
  data() {
    return {
     form:{
       name:"",
       subTitle:"",
       cost:"",
       sn:"",
       price:"",
       content:""
     }
    }
  },
  watch: { // 路由地址不变的情况下,如果id变化则重新获取数据
    $route(newVal, oldVal) {
      console.log(newVal)
      if (newVal.name == 'product-edit' && newVal.query.id != this.id) {
        this.getFindData()
      }
    }
  },
  created() {
       this.getFindData()
  },
  activated() {
  },
  methods: {
    getFindData() {
      this.times = new Date().getSeconds()
      this.id = this.$route.query.id
      var _this = this
      marketProductFind(this.id).then(response => {
        console.log(response)
        _this.form = response.data.jDProduct
      
      }).catch(error => {
        console.log(error.content)
      })
    },
   
  }
}
</script>
